package cn.lbw.spider.monitor.service.impl;

import cn.lbw.spider.monitor.bean.Hello;
import cn.lbw.spider.monitor.dao.HelloDao;
import cn.lbw.spider.monitor.service.IHello;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by lzd on 2017/3/28.
 */

@Transactional
@Service("helloImpl")
public class HelloImpl implements IHello {

    @Autowired
    HelloDao helloDao;

    @Override
    public Hello test() {
        List<Hello> hello = helloDao.findHello();
        System.out.println("拿到的对象个数 = " + hello.size());
        System.out.println("详情见 -->" + hello.get(0));

        return hello.get(0);
    }



    @Override
    public List<Hello> page() {
        PageHelper.startPage(3,5);

        List<Hello> hello = helloDao.findHello();

        System.out.println(hello.size());

        PageInfo<Hello> pageInfo = new PageInfo<>(hello);

        System.out.println(pageInfo.getPageNum());

        return hello;
    }
}
